package org.teamh.gui.login;

import org.teamh.gui.GUI;

import de.lessvoid.nifty.builder.PanelBuilder;
import de.lessvoid.nifty.builder.PopupBuilder;
import de.lessvoid.nifty.controls.button.builder.ButtonBuilder;
import de.lessvoid.nifty.controls.label.builder.LabelBuilder;
import de.lessvoid.nifty.elements.Element;

public class ConLostPopUp {

	private GUI gui;
	private Element errorPopup;

	public ConLostPopUp(GUI gui) {
		this.gui = gui;	
		initErrorPopup();
	}
	
	private void initErrorPopup() {
		new PopupBuilder("cl_error_popup") {{
			backgroundColor("#00000099");
			childLayoutCenter();
			panel(new PanelBuilder() {{
				childLayoutVertical();
				style("nifty-panel");
				width("350px");
				height("200px");
				
				//upper panel for displaying text
				panel(new PanelBuilder() {{
					childLayoutCenter();
					valignCenter();
					height("90px");
					width("330px");
					control(new LabelBuilder("clPopupText") {{
						width("350px");
						text("Connection lost to server!");
						color("#ffffff");
					}});
				}});
				//end upper panel
				
				//lower panel for displaying buttons
				panel(new PanelBuilder() {{
					childLayoutHorizontal();
					valignCenter();
					height("90px");
					width("350px");
					
					panel(new PanelBuilder() {{
						width("350px");
						height("90px");
						childLayoutCenter();
						
						control(new ButtonBuilder("clCloseError", "OK") {{
							visibleToMouse();
							interactOnClick("closeErrorPopup()");
						}});
					}});
				}});
				//end lower panel
			}});
		}}.registerPopup(gui.getNifty());
		
		setErrorPopup(gui.getNifty().createPopup("cl_error_popup"));
	}

	public Element getErrorPopup() {
		return errorPopup;
	}

	public void setErrorPopup(Element errorPopup) {
		this.errorPopup = errorPopup;
	}
	
}

